<?php

namespace app\supply\controller;
use app\common\controller\PCBase;
use app\supply\logic\SupplyLogic;
use Throwable;
use  think\App;
class Supply  extends PCBase
{

    /**
     * 查看列表
     * @throws Throwable
     */
    public function index()
    {

        $params   = $this->request->post();
        return  (new SupplyLogic())->getSupplyList($params);
    }


    /**
     * @desc    供应商编辑列表
     * @date    2024/7/05
     * @author  luckyXiong
     */
    public function edit(){
        $params     = $this->request->post();
        return  (new SupplyLogic())->editSupplyList($params);
    }


    /**
     * @desc    新增供应商列表
     * @date    2024/7/17
     * @author  luckyXiong
     */
    public function addSupplyList(){
        $params     = $this->request->post();
        return  (new SupplyLogic())->addSupplyList($params);
    }


    /**
     * @desc    新增供应商列表
     * @date    2024/7/17
     * @author  luckyXiong
     */
    public function getSupplyList(){
        $params     = $this->request->post();
        $keyword    = $params['keyword']??'';
        $pattern    = '/^[a-zA-Z0-9]+$/';
        if($keyword){
            if(preg_match($pattern, $keyword)) {
                $params['spu']         = $keyword;
            } else {
                $params['supply_name'] = $keyword;
            }
        }
        return  (new SupplyLogic())->get_supply_list($params);
    }



    /**
     * @desc    新增供应商列表
     * @date    2024/7/17
     * @author  luckyXiong
     */
    public function getSupplyListInfo(){
        $params     = $this->request->post();
        $keyword    = $params['keyword']??'';
        $pattern    = '/^[a-zA-Z0-9]+$/';
        if($keyword){
            if(preg_match($pattern, $keyword)) {
                $params['spu']         = $keyword;
            } else {
                $params['supply_name'] = $keyword;
            }
        }
        return  (new SupplyLogic())->get_supplys($params);
    }








    /**
     * @desc    供应商spu关系列表
     * @date    2024/10/22
     * @author  luckyXiong
     */
    public function supply_spu_list(){
        $params     = $this->request->post();
        return  (new SupplyLogic())->get_spu_info($params);
    }



    /**
     * @desc    新增供应商spu关系列表
     * @date    2024/10/22
     * @author  luckyXiong
     */
    public function add_spu_list(){
        $params  = $this->request->post();
        return  (new SupplyLogic())->add_spu_list($params);
    }


    /**
     * @desc    供应商spu关系列表
     * @date    2024/10/22
     * @author  luckyXiong
     */
    public function edit_spu_list(){
        $params     = $this->request->post();
        return  (new SupplyLogic())->edit_spu_list($params);
    }

    /**
     * @desc    删除供应商spu关系列表
     * @date    2024/10/22
     * @author  luckyXiong
     */
    public function delete_spu_list(){
        $params     = $this->request->post();
        return  (new SupplyLogic())->Deletelist($params);
    }


    /**
     * @desc    供应商编辑列表
     * @date    2024/7/05
     * @author  luckyXiong
     */
    public function find(){
        $params     = $this->request->post();
        return  (new SupplyLogic())->findSupplyList($params);
    }







    /**
     * @desc    供应商列表删除
     * @date    2024-07-26
     * @author  luckyXiong
     */
    public function delete(){
        $params     = $this->request->post();
        return  (new SupplyLogic())->delete_supply_list($params);
    }






}